package com.ncpowernode.javaweb.dao;

import com.ncpowernode.javaweb.bean.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BookMapper {

    @Select("select * from t_book;")
    List<Book> selectAll();

    //@Select("select appraise from t_book where id=#{id};")
    //String queryAppraiseById(Long id);

    @Select("select * from t_book where id=#{id}")
    Book selectOneById(Long id);

    @Update("update t_book set appraise=#{appraise}, price=#{price} where book_name=#{bookName};")
    int updateByBookName(@Param("bookName")String bookName,@Param("appraise")String appraise,@Param("price")Double price);

    @Insert("insert into t_book values(null,#{bookName},#{author},#{appraise},#{price});")
    int insert(Book book);

    @Delete("delete from t_book where id=#{id};")
    int deleteById(Long id);
}
